package com.xgggh.redpack.base.ui;

import android.content.Intent;
import android.net.Uri;
import android.widget.Toast;

import com.xgggh.redpack.domain.app.Constant;
import java.util.concurrent.TimeUnit;
import androidx.annotation.NonNull;
import io.reactivex.ObservableTransformer;
import me.drakeet.multitype.Items;
import me.drakeet.multitype.MultiTypeAdapter;

public class BaseActivity extends RxBaseActivity {

    protected MultiTypeAdapter adapter = new MultiTypeAdapter();
    protected Items items = new Items();

    private static final int firstPage=1;
    private int currentPage=firstPage;
    protected static final int size=18;
    protected static final String sort="id,desc";



    protected int firstPage(){
        return firstPage;
    }

    protected int currentPage(){
        return currentPage;
    }
    protected void setCurrentPage(int page){
         currentPage=page;
    }

    protected int nextPage(){
        return currentPage+1;
    }

    public  <T> ObservableTransformer<T, T> uiTransformer() {
        return upstream -> upstream.throttleFirst(Constant.Duration, TimeUnit.SECONDS);
    }


    @NonNull
    public void call(String tel) {
        Uri u;
        try{
            u=Uri.parse("tel:"+tel);
        }catch (Exception e){
            Toast.makeText(this, "电话号码错误", Toast.LENGTH_SHORT).show();
            return;
        }
        Intent intent =new Intent(Intent.ACTION_DIAL);
        intent.setData(u);
        startActivity(intent);
    }
}
